package com.zx.sms.extended;

import com.zx.sms.extended.events.CmppSubmitRequestMsgEvent;
import com.zx.sms.extended.events.CmppSubmitResponseMsgEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;

@Slf4j
public class MsgConsumer {
    public static final String pkg_send = "SEND";// 发送
    public static final String pkg_receive = "RECEIVE";// 接收

    public static final MsgConsumer INS = new MsgConsumer();

    private MsgConsumer(){}

    private ApplicationEventPublisher publisher;
    public void init(ApplicationEventPublisher publisher){
        this.publisher = publisher;
    }



    public void publish(Object obj){
        if (null != publisher){
            publisher.publishEvent(obj);
        }else {
            if (obj instanceof CmppSubmitRequestMsgEvent){
                log.info("CmppSubmitRequestMsgEvent:{}", obj);
                //log.info("打印{}", JSON.toJSONString(obj));
            }else if (obj instanceof CmppSubmitResponseMsgEvent){
                log.info("CmppSubmitResponseMsgEvent:{}", obj);
            }
        }
    }

}
